package com.wang.exception_homework.hw4;

import java.util.Scanner;

public class Demo {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入性别(男/女)：");
        String sex = sc.next();
        try {
            if (!sex.equals("男") && !sex.equals("女")){
                throw new Exception("性别必须是“男”或者“女”！");
            }
            System.out.println("您的性别为：" + sex);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
